using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using System.Linq;
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Microsoft.AspNetCore.Authorization;
using {{namespaceApplicationContracts}};

namespace {{namespace}}
{
    /// <summary>
    /// {{classDescription}}接口
    /// </summary>
    [Route("api/{{projectName}}/{{codeClassName}}")]
    [RemoteService(Name = {{projectName}}RemoteServiceConsts.RemoteServiceName)]
    [Authorize(Permissions.{{projectName}}Permissions.{{entityClassName}}.Default)]
    public class {{className}} :{{controllerBaseClassName}},{{applicationInterfaceClassName}}
    {
        private readonly {{applicationInterfaceClassName}} service;

        public {{className}}({{applicationInterfaceClassName}} service) 
        {
            this.service = service;
        }
        /// <summary>
        /// 新增{{classDescription}}
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize(Permissions.{{projectName}}Permissions.{{entityClassName}}.Create)]
        public async Task<{{dtoClassName}}> CreateAsync({{createOrUpdateClassName}} input)
        {
            return await this.service.CreateAsync(input);
        }

        /// <summary>
        /// 删除{{classDescription}}
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        [Route("{id}")]
        [Authorize(Permissions.{{projectName}}Permissions.{{entityClassName}}.Delete)]
        public async Task DeleteAsync({{idTypeName}} id)
        {
            await this.service.DeleteAsync(id);
        }

        /// <summary>
        /// 查询单个{{classDescription}}
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("{id}")]
        [Authorize(Permissions.{{projectName}}Permissions.{{entityClassName}}.View)]
        public async Task<{{dtoClassName}}> GetAsync({{idTypeName}} id)
        {
            return await this.service.GetAsync(id);
        }
        /// <summary>
        /// 分页查询{{classDescription}}
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize(Permissions.{{projectName}}Permissions.{{entityClassName}}.Default)]
        public async Task<PagedResultDto<{{dtoClassName}}>> GetListAsync({{queryDtoClassName}} input)
        {
            return await this.service.GetListAsync(input);
        }

        /// <summary>
        /// 修改{{classDescription}}
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [Route("{id}")]
        [Authorize(Permissions.{{projectName}}Permissions.{{entityClassName}}.Update)]
        public async Task<{{dtoClassName}}> UpdateAsync({{idTypeName}} id, {{createOrUpdateClassName}} input)
        {
            return await this.service.UpdateAsync(id, input);
        }
    }
}